package necer.ncalendardemo.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.View;

import com.necer.ncalendar.calendar.WeekCalendar;
import com.necer.ncalendar.listener.OnWeekCalendarChangedListener;
import com.ruffian.library.RVPIndicator;

import org.joda.time.LocalDate;

import necer.ncalendardemo.R;

/**
 * Created by necer on 2017/10/30.
 * QQ群:127278900
 */

public class WeekActivity extends Activity {


    private WeekCalendar weekCalendar;
    private RVPIndicator vp;

    /**
     * @param savedInstanceState
     */
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_week);
        final ViewPager viewpager = (ViewPager) findViewById(R.id.viewpager);
        weekCalendar = (WeekCalendar) findViewById(R.id.weekCalendar);

        vp = (RVPIndicator) findViewById(R.id.vp);
        weekCalendar.setOnWeekCalendarChangedListener(new OnWeekCalendarChangedListener(){
            @Override
            public void onWeekCalendarChanged(LocalDate date){
                int dayOfWeek = date.getDayOfWeek();
                Log.e("ddd",""+dayOfWeek);
                if(dayOfWeek==1){
           vp.setViewPager(viewpager,dayOfWeek);
                }
               /* Toast.makeText(WeekActivity.this,date,10).show();*/
            }
        });

        weekCalendar.setDefaultSelect(true);

    }

    public void setDate(View view) {
        weekCalendar.setVisibility(View.VISIBLE);
        weekCalendar.post(new Runnable() {
            @Override
            public void run() {
                weekCalendar.setDate("2017-12-29");
            }
        });


    }


}
